package com.hddf.project.action;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.hddf.project.base.BaseAction;
import com.hddf.project.pojos.Project;
import com.hddf.project.pojos.User;
import com.hddf.project.service.ExcelService;
import com.hddf.project.service.LogsService;
import com.hddf.project.service.ProjectService;
import com.hddf.project.upload_cache.CacheService;
import com.hddf.project.util.ExcelUtil;
import com.hddf.project.util.GetRealPath;
import com.hddf.project.util.O;
import com.hddf.project.util.Stct;
import com.mongodb.DBObject;

//import com.hddf.project.pojos.CheckAnnotations;

public class ProjectAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private List<Project> list;
	private Integer p_id, f_id, s_id, t_id, c_id, srcId, srcType, type;
	private String projectName; // 项目名称
	private String buildSide; // 建设主体
	private String fundPlan; // 资金来源
	private Double fund; // 项目资金
	private String implTime; // 项目实施时间
	private String area; // 所属区县
	private Short comment; // 领导批注
	private String plan; // 项目状态
	private Short ispass; // 是否通过审核 1否 2是
	private String remarks; // 备注
	private String mgrDepart;// 项目主管部门
	private String description;
	private Short checkout;
	private String sign;

	private String startTime, endTime, srcPath, srcName, startFund, endFund, uuid,
			downloadDocumentBySrcIdAndSrcType;
	private Project project;

	private File file;
	private String name, fileFileName, fileContentType, pids;

	/**
	 * 跳转到添加页面
	 * 
	 * @return
	 */
	public String jumpAddProject() {
		setSuccessPath("/page/project/project_add.jsp");
		return SUCCESS;
	}

	/**
	 * 跳转到添加页面
	 * 
	 * @return
	 */
	public String jumpProjectManager() {
		setSuccessPath("/page/project/project_manager.html");
		log(3, "jump project manager");
		return SUCCESS;
	}

	/**
	 * 跳转到文档浏览页面
	 * 
	 * @return
	 */
	public String jumpDocumentBrowsing() {
		try {
			if (srcId != 0 && srcType != 0) {
				ProjectService ps = ProjectService.getInService();
				Map<String, String> map = ps.getSrc(srcId, srcType);
				if (null != map && map.size() > 0) {
					srcName = map.get("srcName");
					srcPath = map.get("srcPath");
				}
				setSuccessPath("/page/project/document_browsing.jsp");
				return SUCCESS;
			} else {
				setSuccessPath("/error_auth.html");
				return ERROR;
			}
		} catch (Exception e) {
			e.printStackTrace();
			setSuccessPath("/error_auth.html");
			return ERROR;
		}
	}

	/**
	 * 浏览项目：高级检索
	 */
	public String jumpBrowseProjectAdvancedSearch() {
		setSuccessPath("/page/browse_project/project_advanced_search.html");
		return SUCCESS;
	}

	/**
	 * 添加项目
	 */
	@SuppressWarnings("unchecked")
	public void addProject() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				if (f_id > 0 && O.ckSt(projectName) && O.ckSt(mgrDepart) && fund > 0 && O.ckSt(implTime)) {
					ProjectService ps = ProjectService.getInService();
					Project p = ps.addProject(f_id, s_id, t_id, projectName, fundPlan, fund, implTime, area, plan,
							remarks, description, mgrDepart, buildSide, sign, user);
					ls = LogsService.getInService();
					ls.addLog(user, "添加项目，项目ID为：" + p.getId() + "，项目名称为：" + p.getName(), (short) 1);

					if (O.ckSt(uuid)) {
						CacheService cas = CacheService.getInstance();
						DBObject obj = cas.getObjById(uuid);
						String path = (String) obj.get(CacheService.PATH_PARAM);
						if (O.ckSt(path)) {// 如果存在
							path = path.substring(path.indexOf(Stct.UPLOAD_PATH_SAVE));
							p.setPath(path);
							ps.updateObject(p);

							int p_id = p.getId();
							List<String> nameList = new ArrayList<String>();
							nameList = (List<String>) obj.get(CacheService.DOCS_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathDoc = path + Stct.UPLOAD_NAME_DOC;
								ps.addDoc(p_id, pathDoc, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目说明书，项目说明书名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.IMGS_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathImg = path + Stct.UPLOAD_NAME_IMG;
								ps.addImg(p_id, pathImg, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目设计图，项目设计图名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.TABLES_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathTbale = path + Stct.UPLOAD_NAME_TABLE;
								ps.addTable(p_id, pathTbale, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目三表，项目三表名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.APPROVAL_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathApproval = path + Stct.UPLOAD_NAME_APPROVAL;
								ps.addApproval(p_id, pathApproval, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目批件，项目批件名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.CHECKS_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathCheck = path + Stct.UPLOAD_NAME_CHECK;
								ps.addCheck(p_id, pathCheck, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目部门意见，项目部门意见名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.VIDEO_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathVideo = path + Stct.UPLOAD_NAME_VIDEO;
								ps.addVideo(p_id, pathVideo, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目视频，项目视频名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.OTHER_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathOther = path + Stct.UPLOAD_NAME_OTHER;
								ps.addOther(p_id, pathOther, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目其他文件，项目其他文件名称为：" + realName, (short) 1);
								}
							}
						}
						cas.deleteById(uuid);
					}
					log(3, "add project", p.getId(), p.getName());
				} else {
					state = "error";
					msg = "请填写正确内容";
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "添加失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 根据类别ID获取项目
	 */
	public void getProjectsByCategory() {
		try {
			int result = 0;
			List<Project> pList = null;
			ProjectService ps = ProjectService.getInService();
			page = (page - 1) * lengthData;
			if (O.ckNm(type)) {
				switch (type) {
				case 1:
					f_id = c_id;
					break;
				case 2:
					s_id = c_id;
					break;
				case 3:
					t_id = c_id;
					break;
				}
			}
			int userid = 0;
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				userid = user.getId();
			}
			pList = ps.getProjectsByCategory(page, lengthData, f_id, s_id, t_id, projectName, startTime, endTime,
					startFund, endFund, mgrDepart, buildSide, plan, area, ispass, comment, checkout, userid);
			result = ps.getProjectsCountByMoreConditions(f_id, s_id, t_id, projectName, startTime, endTime,
					startFund, endFund, mgrDepart, buildSide, plan, area, ispass, comment, checkout);
			msg = pList;
			map.put("pageCount", getPageCount(result));
			log(4, "get projects by more conditions");
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 根据ID获取项目的明细信息
	 * 
	 * @return
	 */
	public String getProjectDetailedById() {
		try {
			if (p_id != 0) {
				ProjectService ps = ProjectService.getInService();
				project = ps.getProjectDetailedById(p_id);
				log(4, "get project detailed by project id", p_id);
				setSuccessPath("/page/project/project_detailed.jsp");
				return SUCCESS;
			} else {
				setSuccessPath("/error_auth.html");
				return ERROR;
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
			setSuccessPath("/error.html");
			return ERROR;
		}
	}

	/**
	 * 跳转到修改页面
	 * 
	 * @return
	 */
	public String jumpProjectUpdate() {
		try {
			ProjectService ps = ProjectService.getInService();
			if (p_id != 0) {
				project = ps.getProjectDetailedById(p_id);
				setSuccessPath("/page/project/project_update.jsp");
				return SUCCESS;
			} else {
				setSuccessPath("/error_auth.html");
				return ERROR;
			}
		} catch (Exception e) {
			e.printStackTrace();
			setSuccessPath("/error.html");
			return ERROR;
		}
	}

	/**
	 * 删除上传
	 */
	public void deleteUpload() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				if (srcId != 0 && srcType != 0) {
					ProjectService ps = ProjectService.getInService();
					boolean tof = ps.deleleUpload(srcId, srcType);
					if (!tof) {
						state = "error";
						msg = "删除失败";
					} else {
						String name = "";
						switch (srcType) {
						case Stct.UPLOAD_TYPE_DOC:
							name = Stct.UPLOAD_NAME_DOC;
							break;
						case Stct.UPLOAD_TYPE_IMG:
							name = Stct.UPLOAD_NAME_IMG;
							break;
						case Stct.UPLOAD_TYPE_TABLE:
							name = Stct.UPLOAD_NAME_TABLE;
							break;
						case Stct.UPLOAD_TYPE_APPROVAL:
							name = Stct.UPLOAD_NAME_APPROVAL;
							break;
						case Stct.UPLOAD_TYPE_CHECK:
							name = Stct.UPLOAD_NAME_CHECK;
							break;
						case Stct.UPLOAD_TYPE_VIDEO:
							name = Stct.UPLOAD_NAME_VIDEO;
							break;
						}
						log(3, "delete upload file and folder", srcId, name);

						ls = LogsService.getInService();
						ls.addLog(user, "删除" + name + "，" + name + "ID为：" + srcId, (short) 3);
					}
				} else {
					state = "error";
					msg = "删除失败";
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 修改项目
	 */
	@SuppressWarnings("unchecked")
	public void updateProject() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				if (p_id != 0 && f_id != 0 && O.ckSt(projectName) && O.ckSt(mgrDepart) && O.ckSt(fund)
						&& O.ckSt(implTime)) {
					ProjectService ps = ProjectService.getInService();
					Project p = ps.updateProject(f_id, s_id, t_id, projectName, buildSide, fundPlan, fund,
							implTime, area, plan, remarks, description, mgrDepart, p_id, sign);

					ls = LogsService.getInService();
					ls.addLog(user, "修改项目，项目ID为：" + p_id + "，项目名称为：" + projectName, (short) 2);

					if (O.ckSt(uuid)) {
						CacheService cas = CacheService.getInstance();
						DBObject obj = cas.getObjById(uuid);
						String path = (String) obj.get(CacheService.PATH_PARAM);
						if (O.ckSt(path)) {// 如果存在

							path = path.substring(path.indexOf(Stct.UPLOAD_PATH_SAVE));
							if (!O.ckSt(p.getPath())) {
								p.setPath(path);
								ps.updateObject(p);
							}
							int p_id = p.getId();
							List<String> nameList = new ArrayList<String>();
							nameList = (List<String>) obj.get(CacheService.DOCS_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathDoc = path + Stct.UPLOAD_NAME_DOC;
								ps.addDoc(p_id, pathDoc, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目说明书，项目说明书名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.IMGS_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathImg = path + Stct.UPLOAD_NAME_IMG;
								ps.addImg(p_id, pathImg, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目设计图，项目设计图名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.TABLES_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathTbale = path + Stct.UPLOAD_NAME_TABLE;
								ps.addTable(p_id, pathTbale, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目三表，项目三表名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.APPROVAL_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathApproval = path + Stct.UPLOAD_NAME_APPROVAL;
								ps.addApproval(p_id, pathApproval, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目批件，项目批件名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.CHECKS_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathCheck = path + Stct.UPLOAD_NAME_CHECK;
								ps.addCheck(p_id, pathCheck, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目部门意见，项目部门意见名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.VIDEO_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathVideo = path + Stct.UPLOAD_NAME_VIDEO;
								ps.addVideo(p_id, pathVideo, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目视频，项目视频名称为：" + realName, (short) 1);
								}
							}

							nameList = (List<String>) obj.get(CacheService.OTHER_TYPE);
							if (null != nameList && !nameList.isEmpty()) {
								String pathOther = path + Stct.UPLOAD_NAME_OTHER;
								ps.addOther(p_id, pathOther, nameList);

								for (int i = 0; i < nameList.size(); i++) {
									String fileName = nameList.get(i);
									String[] name = fileName.split(":::");
									String realName = name[0];// 真实的名字
									ls.addLog(user, "添加项目其他文件，项目其他文件名称为：" + realName, (short) 1);
								}
							}
						}
						cas.deleteById(uuid);
					}
					log(3, "update project", p.getId(), p.getName());
				} else {
					state = "error";
					msg = "请填写正确内容";
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "修改失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 删除项目
	 */
	public void deleteProject() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				if (p_id != 0) {
					ProjectService ps = ProjectService.getInService();
					ps.deleteProject(p_id);
					log(3, "delete project", p_id);

					ls = LogsService.getInService();
					ls.addLog(user, "修改项目，项目ID为：" + p_id + "，项目名称为：" + projectName, (short) 3);
				} else {
					state = "error";
					msg = "请填写正确内容";
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "修改失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 根据类别ID获取项目
	 */
	public void getProjectAdvancedSearch() {
		try {
			int result = 0;
			List<Project> pList = null;
			ProjectService ps = ProjectService.getInService();
			page = (page - 1) * lengthData;
			int userid = 0;
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				userid = user.getId();
			}
			pList = ps.getProjectsByCategory(page, lengthData, f_id, s_id, t_id, projectName, startTime, endTime,
					startFund, endFund, mgrDepart, buildSide, plan, area, ispass, comment, checkout, userid);
			result = ps.getProjectsCountByMoreConditions(f_id, s_id, t_id, projectName, startTime, endTime,
					startFund, endFund, mgrDepart, buildSide, plan, area, ispass, comment, checkout);
			msg = pList;
			map.put("pageCount", getPageCount(result));
			log(4, "advanced search project by more conditions");
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 浏览项目：高级检索
	 */
	public String jumpProjectList() {
		setSuccessPath("/page/browse_project/project_list.html");
		return SUCCESS;
	}

	/**
	 * 根据储备、在建、完成查询项目数量
	 */
	public void getProjectCountByTime() {
		try {
			ProjectService ps = ProjectService.getInService();
			List<Integer> list = ps.getProjectsCountByTime();
			msg = list;
			log(4, "According to the number of time query project");
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 浏览项目：跳转到项目名称查询页面
	 */
	public String jumpProjectNameSearch() {
		setSuccessPath("/page/browse_project/project_name_search.html");
		return SUCCESS;
	}

	// /**
	// * 批示处理
	// */
	// public void projectNotation() {
	// try {
	// User user = (User) getRequest().getAttribute("user");
	// if (null != user) {
	// if (0 != p_id) {
	// ProjectService ps = ProjectService.getInService();
	// ps.projectNotation(p_id, comment);
	// log(3, "leadership instructions", p_id, comment);
	//
	// ls = LogsService.getInService();
	// ls.addLog(user, "进行项目批示，项目ID为：" + p_id, (short) 1);
	// } else {
	// state = "error";
	// msg = "批示失败";
	// }
	// } else {
	// state = "error";
	// msg = "请登录后在进行操作！";
	// }
	// } catch (Exception e) {
	// state = "error";
	// msg = "操作失败";
	// e.printStackTrace();
	// } finally {
	// map.put("state", state);
	// map.put("msg", msg);
	// printHttpServletResponse(getJson(map));
	// }
	// }

	// /**
	// * 检测是否有改动的批示
	// */
	// public void getUpdateNotation() {
	// try {
	// ProjectService ps = ProjectService.getInService();
	// List<CheckAnnotations> acList = ps.getUpdateNotation();
	// msg = acList;
	// } catch (Exception e) {
	// state = "error";
	// msg = "操作失败";
	// e.printStackTrace();
	// } finally {
	// map.put("state", state);
	// map.put("msg", msg);
	// printHttpServletResponse(getJson(map));
	// }
	// }

	/**
	 * 下载
	 */
	public String jumpDownloadDocument() {
		User user = (User) getRequest().getAttribute("user");
		if (null != user) {
			setDownloadDocumentBySrcIdAndSrcType("/page/project/download_document.jsp?srcId=" + srcId
					+ "&srcType=" + srcType);

			ls = LogsService.getInService();
			ls.addLog(user, "下载项目相关文件，项目文件ID为：" + srcId + "，文件类别为：" + srcType, (short) 4);

			return "downloadDocumentBySrcIdAndSrcType";
		} else {
			return "login";
		}
	}

	/**
	 * 校验
	 */
	public void projectCheckout() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				if (0 != p_id) {
					ProjectService ps = ProjectService.getInService();
					ps.projectCheckout(p_id);
					log(3, "checkout product", p_id);

					ls = LogsService.getInService();
					ls.addLog(user, "校验项目，项目ID为：" + p_id, (short) 2);
				} else {
					state = "error";
					msg = "校验失败";
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	public String jumpImplExcel() {
		setSuccessPath("/page/project/impl_excel.jsp");
		log(3, "jump impl excel");
		return SUCCESS;
	}

	/**
	 * 导入excel基础数据
	 */
	public void implExcelBasis() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				List<List<String>> tempList = ExcelUtil.realExcel(file, name, true);
				if (O.ckLt(tempList) && tempList.size() > 6) {
					ProjectService ps = ProjectService.getInService();
					ps.addMoreProjectBasis(user, tempList);

					ls = LogsService.getInService();
					ls.addLog(user, "批量导入项目基础数据", (short) 1);
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 导入excel详情数据
	 */
	public void implExcelDetail() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				List<List<String>> tempList = ExcelUtil.realExcel(file, name, true);
				if (O.ckLt(tempList) && tempList.size() > 7) {
					ProjectService ps = ProjectService.getInService();
					ps.addMoreProjectDetail(user, tempList);

					ls = LogsService.getInService();
					ls.addLog(user, "批量导入项目详情数据", (short) 1);
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 导入excel结转完整数据
	 */
	public void implExcelSwerve() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				List<List<String>> tempList = ExcelUtil.realExcel(file, name, true);
				if (O.ckLt(tempList) && tempList.size() > 6) {
					ProjectService ps = ProjectService.getInService();
					Map<String, Integer> tempMap = ps.addMoreProjectSwerve(user, tempList);

					GetRealPath gtrlph = new GetRealPath();
					String prefix = name.substring(0, name.lastIndexOf("."));
					String suffix = name.substring(name.lastIndexOf(".") + 1);
					String path = gtrlph.getRealPath() + "file/" + prefix + "_已导." + suffix;
					O.saveFile(file, path);

					ExcelService es = ExcelService.getInService();
					es.idExcel(path, name, tempMap);

					ls = LogsService.getInService();
					ls.addLog(user, "批量导入项目转结完整数据", (short) 1);
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 获取类别为空的项目
	 */
	public void listProjectCategory() {
		try {
			ProjectService ps = ProjectService.getInService();
			List<Project> pList = ps.listProjectCategory();
			msg = pList;
			log(3, "获取类别为空的项目");
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	public String jumpUpdateMoreCategory() {
		setSuccessPath("/page/project/update_more_category.html");
		log(3, "跳转到批量修改项目类别页面");
		return SUCCESS;
	}

	/**
	 * 批量添加类别
	 */
	public void updateMoreCategory() {
		try {
			User user = (User) getRequest().getAttribute("user");
			if (null != user) {
				if (O.ckNm(f_id) && O.ckNm(s_id) && O.ckSt(pids)) {
					ProjectService ps = ProjectService.getInService();
					ps.updateMoreCategory(f_id, s_id, t_id, pids);

					ls = LogsService.getInService();
					ls.addLog(user, "批量修改项目类别", (short) 2);
				} else {
					state = "error";
					msg = "请选择类别或者项目";
				}
			} else {
				state = "error";
				msg = "请登录后在进行操作！";
			}
		} catch (Exception e) {
			state = "error";
			msg = "操作失败";
			e.printStackTrace();
		} finally {
			map.put("state", state);
			map.put("msg", msg);
			printHttpServletResponse(getJson(map));
		}
	}

	/**
	 * 跳转到项目计划操作页面
	 * 
	 * @return
	 */
	public String jumpPlanItem() {
		log(3, "跳转到项目计划操作页面");
		setSuccessPath("/page/project/plan_item.jsp");
		return SUCCESS;
	}

	public List<Project> getList() {
		return list;
	}

	public void setList(List<Project> list) {
		this.list = list;
	}

	public Integer getF_id() {
		return f_id;
	}

	public void setF_id(Integer f_id) {
		this.f_id = f_id;
	}

	public Integer getS_id() {
		return s_id;
	}

	public void setS_id(Integer s_id) {
		this.s_id = s_id;
	}

	public void setT_id(Integer t_id) {
		this.t_id = t_id;
	}

	public Integer getT_id() {
		return t_id;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getBuildSide() {
		return buildSide;
	}

	public void setBuildSide(String buildSide) {
		this.buildSide = buildSide;
	}

	public String getFundPlan() {
		return fundPlan;
	}

	public void setFundPlan(String fundPlan) {
		this.fundPlan = fundPlan;
	}

	public double getFund() {
		return fund;
	}

	public void setFund(double fund) {
		this.fund = fund;
	}

	public String getPlan() {
		return plan;
	}

	public void setPlan(String plan) {
		this.plan = plan;
	}

	public Short getIspass() {
		return ispass;
	}

	public void setIspass(Short ispass) {
		this.ispass = ispass;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getImplTime() {
		return implTime;
	}

	public void setImplTime(String implTime) {
		this.implTime = implTime;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public Integer getC_id() {
		return c_id;
	}

	public void setC_id(Integer c_id) {
		this.c_id = c_id;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public Integer getP_id() {
		return p_id;
	}

	public void setP_id(Integer p_id) {
		this.p_id = p_id;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public Integer getSrcId() {
		return srcId;
	}

	public void setSrcId(Integer srcId) {
		this.srcId = srcId;
	}

	public Integer getSrcType() {
		return srcType;
	}

	public void setSrcType(Integer srcType) {
		this.srcType = srcType;
	}

	public String getSrcPath() {
		return srcPath;
	}

	public void setSrcPat(String srcPath) {
		this.srcPath = srcPath;
	}

	public String getSrcName() {
		return srcName;
	}

	public void setSrcName(String srcName) {
		this.srcName = srcName;
	}

	public String getMgrDepart() {
		return mgrDepart;
	}

	public void setMgrDepart(String mgrDepart) {
		this.mgrDepart = mgrDepart;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setSrcPath(String srcPath) {
		this.srcPath = srcPath;
	}

	public String getStartFund() {
		return startFund;
	}

	public void setStartFund(String startFund) {
		this.startFund = startFund;
	}

	public String getEndFund() {
		return endFund;
	}

	public void setEndFund(String endFund) {
		this.endFund = endFund;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getDownloadDocumentBySrcIdAndSrcType() {
		return downloadDocumentBySrcIdAndSrcType;
	}

	public void setDownloadDocumentBySrcIdAndSrcType(String downloadDocumentBySrcIdAndSrcType) {
		this.downloadDocumentBySrcIdAndSrcType = downloadDocumentBySrcIdAndSrcType;
	}

	@Override
	public LogsService getLs() {
		return ls;
	}

	@Override
	public void setLs(LogsService ls) {
		this.ls = ls;
	}

	public Short getCheckout() {
		return checkout;
	}

	public void setCheckout(Short checkout) {
		this.checkout = checkout;
	}

	public Short getComment() {
		return comment;
	}

	public void setComment(Short comment) {
		this.comment = comment;
	}

	@Override
	public File getFile() {
		return file;
	}

	@Override
	public void setFile(File file) {
		this.file = file;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String getFileFileName() {
		return fileFileName;
	}

	@Override
	public void setFileFileName(String fileFileName) {
		this.fileFileName = fileFileName;
	}

	@Override
	public String getFileContentType() {
		return fileContentType;
	}

	@Override
	public void setFileContentType(String fileContentType) {
		this.fileContentType = fileContentType;
	}

	public void setFund(Double fund) {
		this.fund = fund;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getPids() {
		return pids;
	}

	public void setPids(String pids) {
		this.pids = pids;
	}

}